package com.ruoyi.ftrl.mapper;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.ruoyi.ftrl.domain.Dto.*;
import com.ruoyi.ftrl.domain.EquipmentDocking;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 室温实时数据Mapper接口
 * 
 * @author dihang
 * @date 2024-07-09
 */
public interface EquipmentDockingMapper 
{


    // 批量查询室外温度
    List<Double> selectWeatherTime(String startTime, String endTime);

    // 批量查询指定热力站的温度数据
//    List<StationTemperature> selectTempTimesBatch(@Param("stationNames") List<String> stationNames,
//                                                  @Param("startTime") String startTime,
//                                                  @Param("endTime") String endTime);

    List<StationTemperature> selectTempTimesBatch( Map<String, Object> params);


    /**
     * 查询室温实时数据
     * 
     * @param id 室温实时数据主键
     * @return 室温实时数据
     */
    public EquipmentDocking selectEquipmentDockingById(Long id);

    /**
     * 查询室温实时数据列表
     * 
     * @param equipmentDocking 室温实时数据
     * @return 室温实时数据集合
     */
    public List<EquipmentDocking> selectEquipmentDockingList(EquipmentDocking equipmentDocking);

    /**
     * 新增室温实时数据
     * 
     * @param equipmentDocking 室温实时数据
     * @return 结果
     */
    public int insertEquipmentDocking(EquipmentDocking equipmentDocking);

    /**
     * 修改室温实时数据
     * 
     * @param equipmentDocking 室温实时数据
     * @return 结果
     */
    public int updateEquipmentDocking(EquipmentDocking equipmentDocking);

    /**
     * 删除室温实时数据
     * 
     * @param id 室温实时数据主键
     * @return 结果
     */
    public int deleteEquipmentDockingById(Long id);

    /**
     * 批量删除室温实时数据
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteEquipmentDockingByIds(Long[] ids);

    /**
     * 查询黑蚂蚁历史数据
     * @return
     */
    List<EquipmentDocking> selectEquipmentDockingHistory();

    void updateEquipmentDockingHistory(Long id);

    /**
     * 查询室温历史数据列表
     * @param equipmentDocking
     * @return
     */
    List<EquipmentDocking> selectHistoryEquipmentDocking(EquipmentDocking equipmentDocking);

    /**
     * 根据设备号查询温度详情
     * @param nodeId
     * @return
     */
    EquipmentDocking selectEquipmentDockingByNodeId(String nodeId);

    EquipmentDocking selectEquipmentCountDockingById(String  roomNo);

    EquipmentDocking  selectEquipmentCountDockingList(@Param("roomNo")String  roomNo, @Param("startTime")Date startTime, @Param("endTime")Date endTime);

    List<EquipmentDocking> selectEquipmentCountDockingByRoomNo(String roomNo);

    List<EquipmentDocking> selectEquipmentCountDockingByRoomNos(@Param("roomNo")String  roomNo, @Param("startTime")Date startTime, @Param("endTime")Date endTime);

    List<EquipmentDocking>selectEquipmentCountDockingByRoomNoss(Map<String, Object> params);

    EquipmentDocking selectEquipmentCountDockingCount();

    EquipmentDocking selectEquipmentCountDockingByRoom(String roomNo);

    EquipmentDocking  selectEquipmentCountDockingByTime(@Param("date")Date date, @Param("roomNo")String roomNo);

    /**
     * 根据房间号和日期查询温度平均值
     * @param params 包含房间号和日期的参数
     * @return 温度平均值
     */
    Double selectEquipmentCountDockingByTimes(Map<String, Object> params);

    List<EquipmentDocking> selectEquipmentCountDockingByRooms(String roomNo);

    List<EquipmentDocking> selectEquipmentCountDockingByRoomsAndTIme(@Param("roomNo")String  roomNo, @Param("startTime")Date startTime, @Param("endTime")Date endTime);

    EquipmentDocking selectEquipmentDockingTemp(String roomNo);

    EquipmentDocking selectEquipmentDockingByNodeCode(String imei);

    /**
     * 根据小区名称和日期查询温度平均值
     * @param params 包含房间号和日期的参数
     * @return 温度平均值
     */
    Long selectEquipmentCountDockingByTimesName(Map<String, Object> params);

    List<EquipmentDocking> selectEquipmentCountDockingByRoomss(String roomNo);

    EquipmentDocking selectByNameAvg(String name);


    List<String > selectTimeAxis();

    List<String > selectTimeAxiss(@Param("startTime")String startTime, @Param("endTime")String endTime);

    List<Double> selectTempWeek(String name);

    List<Double> selectTempTime(@Param("name")String name,@Param("startTime")Date startTime, @Param("endTime")Date endTime);

    List<Double> selectTempWeeks(String name);

    List<Double> selectTempTimes(@Param("name")String name,@Param("startTime")String startTime, @Param("endTime")String endTime);

    List<EquipmentDocking> selectEquipmentDockingByNodeCodes(String imei);


    void updateEquipmentDockingHistorys(@Param("id")Long id, @Param("uploadtime")Date uploadtime);

    List<BigDecimal> getTemperaturesByCommunityName(String communityName);

    @Select("SELECT * FROM equipment_docking WHERE history = 1")
    List<EquipmentDocking> selectCurrentRecords();

//    @Select("SELECT temp FROM equipment_docking WHERE history = 1")
    List<BigDecimal> selectCurrentTemperatures();

    Map<String, Integer> selectTemperatureCounts();

    /**
     * 查询每个小区的平均温度
     *
     * @return 小区平均温度列表
     */
    List<AvgTempDto> selectAvgTempByTimeRange(@Param("startTime") String startTime,
                                              @Param("endTime") String endTime,
                                              @Param("villageNames") List<String> villageNames);
    /**
     * 获取最高室温数据
     * @return
     */
    List<EquipmentDocking> selectEquipmentDockingListMax();

    /**
     * 获取最低室温数据
     * @return
     */
    List<EquipmentDocking> selectEquipmentDockingListMin();

    List<EquipmentDocking> selectByCommunityNames(@Param("communityNames") List<String> communityNames);
    List<EquipmentDocking> batchSelectTemperatureStats(@Param("communityNames") List<String> communityNames);

    List<EquipmentDocking> selectByCommunityIds(@Param("ids") List<Long> ids);
    List<EquipmentDocking> selectByCommunityNamess(@Param("communityNames") List<String> communityNames);

    Double selectCommunityInfoAvg(String name);

    Long selectAvgTemperatureByStationAndTime(Map<String, Object> params);

    /**
     * 查询指定小区的平均温度
     * @param villageName 小区名称
     * @return 平均温度
     */
    Double selectAvgTemperatureByName(@Param("villageName") String villageName);

    List<Long> selectAvgTemperatureByStationAndDates(Map<String, Object> params);

//    List<EquipmentDocking> selectEquipmentDailyAverage(@Param("roomNo")String roomNo, @Param("startTime")Date startTime,@Param("endTime") Date endTime);
    List<Equipments> selectEquipmentDailyAverage(@Param("roomNo")String roomNo, @Param("startTime")Date startTime, @Param("endTime") Date endTime);

    List<DailyTemperatureDto> selectDailyTemperature(@Param("roomNo")String roomNo, @Param("startTime")Date startTime, @Param("endTime")Date endTime);

    /**
     * 根据房间编号数组查询设备对接数据
     *
     * @param roomNos 房间编号数组
     * @return 设备对接数据集合
     */
    public List<EquipmentDocking> selectEquipmentDockingByRoomNos(@Param("roomNos") String[] roomNos);


//    List<Long> selectAvgTemperatureByStationAndDates(List<Date> dates, List<String> communityNames);
}


